package cn.autumnorange.app.scheduletask.consumer.security;

import cn.autumnorange.app.common.consumer.security.AbstractResourceServerConfigurer;
import cn.autumnorange.app.common.rpc.security.HttpSessionRequestCacheWrapper;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.web.savedrequest.RequestCache;

@Configuration
@EnableResourceServer
@EnableGlobalMethodSecurity(prePostEnabled = true) // 方法上开启注解权限方式
public class ResourceServerConfigurer extends AbstractResourceServerConfigurer {
  // 注入自定义RequestCache
  @Override
  public void configure(HttpSecurity http) throws Exception {
    http.setSharedObject(RequestCache.class, new HttpSessionRequestCacheWrapper());
    super.configure(http);
  }
}
